package API.Collection.Set.HashSet;

import java.util.HashSet;
import java.util.Set;

public class Test {
    public static void main(String[] args) {
        // HashSet采用数组+链表+红黑树的方式存储数据
        Set<Student> set = new HashSet<>();
        Student student1 = new Student("Jack", 18, "2023001");
        Student student2 = new Student("Nick", 19, "2023002");
        Student student3 = new Student("John", 20, "2023003");
        Student student4 = new Student("Jack", 18, "2023001");
        set.add(student1);
        set.add(student2);
        set.add(student3);
        set.add(student4);
        // 可以看出他们的地址并不连续，且只有三个元素(无序,数据不重复)
        for(Student student : set) {
            System.out.println(student);
        }
    }
}
